import { useContext } from "react";
import ThemeContext from "./context/ThemeContext";

const UseContext = ()=>{
  // 3. 在任意后代中通过useContext拿到任意Context的值
  const value = useContext(ThemeContext);
  console.log('value...', value);
  return <div>
    <p>拿到themeContext的值：{value.list.map((item, index)=>{
      return <li key={item}>{`第${index}个值是：${item}`}</li>
    })}</p>
    <button onClick={()=>value.cb('我是来自useContext的消息')}>执行ThemeContext的回调</button>
  </div>
}

export default UseContext;
